import GlobalVariable
import my_influxdb3
import my_config



# 主操作
def main():
    macs = GlobalVariable.have_cahe_macs.split('&')
    for mac in macs:
        GlobalVariable.final_result = {}
        my_config.todayPointDetail(mac, 3)
        pointInfos= GlobalVariable.final_result["pointInfos"]
        cache_info_list=pointInfos.get('cache_info_list')
        print(cache_info_list)
        client = my_influxdb3.creat_client()
        # 传一个tag  多个file时要传一个集合 不支持中文
        my_influxdb3.add(client, "JD", mac, cache_info_list)




# endregion

def runTest(i):
    if i > 10:
        return
    # try:
    if GlobalVariable.WSKEY is None or GlobalVariable.WSKEY.strip() == '':
        print("未获取到环境变量'WSKEY'，执行中止")
        return
    GlobalVariable.headers["wskey"] = GlobalVariable.WSKEY
    GlobalVariable.service_headers["tgt"] = GlobalVariable.WSKEY
    main()
    # except Exception as e:
    #     print("出现错误：", e)
    #     print("准备重新执行...")
    #     time.sleep(60)
    #     runTest(++i)


# 读取配置文件
if __name__ == '__main__':
    runTest(0)

